package cn.hloger.spider.demo.proxyDemo.config;

import cn.hloger.spider.demo.proxyDemo.interceptor.ZhyReqInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author huanglong
 * @version 1.0
 * @date 2024/2/1
 */
@Configuration(value = "proxyDemoWebConfig")
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private ZhyReqInterceptor zhyReqInterceptor;

    @Value("${proxy.url.flag:false}")
    private boolean proxyUrlFLag;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        if (!proxyUrlFLag) {
            return;
        }
        registry.addInterceptor(zhyReqInterceptor);
    }
}